/**
 * Created by qsyan on 2016-11-27.
 */

import {
    SELECT_ROW,
    LOAD,
    LOAD_ALL_PENDING,
    LOAD_ALL_SUCCESS,
    GET_BY_ID_SUCCESS
} from '../actions/example';
const initialState = {
    selectedRowKeys: [],
    selectedRowIds:[],
    list: [],
    total: 0,
    pageNo: 1,
    pageSize: 10,
    data: {}
};
export default function example(state = initialState, action = {}) {
    switch (action.type) {
        case SELECT_ROW:
            return Object.assign({}, state, {selectedRowKeys: action.payload.data.ids,selectedRowIds:action.payload.data.rows});
        case LOAD_ALL_SUCCESS:
            return {
                ...state,
                list: action.payload.data,
                total: action.payload.total
            };
        case GET_BY_ID_SUCCESS:
            return {
                ...state,
                data: action.payload
            };
        default:
            return state;
    }
}